/*
 * Copyright (C) 2010 Zaizi Limited.
 *
 * This file is part of Zaizi's Alfresco FISE integration
 * 
 * Alfresco FISE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Alfresco FISE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Alfresco FISE. If not, see <http://www.gnu.org/licenses/>.
 */
package org.zaizi.fiseiks.alfresco.service;

import java.io.Serializable;

import org.alfresco.service.cmr.repository.NodeRef;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Basic content bean
 * 
 * @author efoncubierta
 *
 */
public class BasicContent implements Serializable
{

	private static final long serialVersionUID = 4456979755286857776L;
	
	private NodeRef nodeRef;
	private String title;

	/**
	 * Get node reference
	 * 
	 * @return Node reference
	 */
	public NodeRef getNodeRef()
	{
		return nodeRef;
	}

	/**
	 * Set node reference
	 * 
	 * @param nodeRef Node reference
	 */
	public void setNodeRef(NodeRef nodeRef)
	{
		this.nodeRef = nodeRef;
	}

	/**
	 * Get content title
	 * 
	 * @return Content title
	 */
	public String getTitle()
	{
		return title;
	}

	/**
	 * Set content title
	 * 
	 * @param title Content title
	 */
	public void setTitle(String title)
	{
		this.title = title;
	}
	
	/**
	 * Convert to a JSON String
	 * 
	 * @return JSON String
	 */
	public String toJsonString()
	{
		return toJSONObject().toString();
	}
	
	/**
	 * Convert to a JSON object
	 * 
	 * @return JSON object
	 */
	public JSONObject toJSONObject()
	{
		final JSONObject obj = new JSONObject();
		
		try
		{
			obj.put("nodeRef", nodeRef);
			obj.put("title", title);
		}
		catch (JSONException e)
		{
			// TODO: Nothing to do
		}
		
		return obj;
	}
}
